package BuilderDemo.exp2;

/**
 * @author zsh
 * @Description 抽象类Builder
 * @create 2022-05-30 19:39
 */
public abstract class Builder {
    private boolean initialized = false;  //是否进行了创建标题

    public void makeTitle(String title){
        if (!initialized){  //没有创建标题则创建
            buildTitle(title);
            initialized = true;  //一个实例仅允许创建一次标题
        }
    }

    public void makeString(String title){
        if (initialized){
            buildString(title);
        }
    }

    public void makeItems(String[] items) {
        if (initialized) {
            buildItems(items);
        }
    }

    public void close() {
        if (initialized) {
            buildDone();
        }
    }

    public abstract void buildTitle(String title);
    public abstract void buildString(String str);
    public abstract void buildItems(String[] items);
    public abstract void buildDone();
}
